<template>
  <div class="feed">
    <div class="feed-box">
      <div class="feed-head">
        <div class="feed-title flex align-center">
          <img src="../../assets/images/feed-title.png" alt="" />我要反馈
        </div>
      </div>
      <div class="dia-body">
        <div>
          <span class="db-title flex flex-end">站点名称:</span>
          <el-input
            class="common-inp"
            type="textarea"
            resize="none"
            placeholder="请输入站点名称"
            v-model="codeInput"
          ></el-input>
        </div>
        <div>
          <span class="db-title flex flex-end">网址:</span>
          <el-input
            class="common-inp"
            type="textarea"
            resize="none"
            placeholder="请输入网址"
            v-model="urlInput"
          ></el-input>
        </div>
        <div style="margin-bottom: 20px">
          <span class="db-title flex flex-end">反馈内容:</span
          ><el-input
            class="feed-inp"
            type="textarea"
            resize="none"
            placeholder="请仔细填写内部反馈信息"
            v-model="contentInput"
          ></el-input>
        </div>
        <div>
          <span class="db-title flex flex-end">联系电话:</span>
          <el-input
            class="common-inp"
            type="textarea"
            resize="none"
            placeholder="请输入电话号码"
            v-model="telInput"
          ></el-input>
        </div>
      </div>
      <div class="dialog-footer flex just-center">
        <el-button class="send-btn" type="primary" @click="sendFeed"
          >确 定</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { post } from "../../axios/request";
export default {
  data() {
    return {
      dialogFormVisible3: true,
      codeInput: "",
      urlInput: "",
      contentInput: "",
      telInput: "",
      userName: "",
    };
  },

  created() {
    this.userName = localStorage.getItem("userName") || "小图";
  },
  methods: {
    /**
     * 发送反馈事件
     */
    sendFeed() {
      if (this.codeInput == "") {
        this.$message.error(`请输入城市代码`);
        return;
      } else if (this.urlInput == "") {
        this.$message.error(`请输入反馈网址`);
        return;
      } else if (this.contentInput == "") {
        this.$message.error(`请输入反馈内容`);
        return;
      }
      let data = {
        ac: "inner_feed",
        username: this.userName,
        city_name: this.codeInput,
        url: this.urlInput,
        feed_content: this.contentInput,
        tel: this.telInput,
      };
      post("index.php", data).then((res) => {
        if (res.data.code == 0) {
          this.$message({
            message: "反馈内容已提交!",
            type: "success",
          });
          this.codeInput = "";
          this.urlInput = "";
          this.contentInput = "";
          this.telInput = "";
        } else {
          this.$message.error(`${res.data.msg}`);
        }
      });
    },

    /**
     * 获取已完结信息
     */
    getFinish(pages) {
      let data = {
        status: "4",
        size: 10,
      };
      get(`index.php?ac=list&page=${pages}`, data).then((res) => {
        if (res.data.code === -2) {
          window.location.replace("https://houtai.wh.bendibao.com/login.php");
        } 
      });
    },
  },
};
</script>

<style>
@import "./feed.css";
.feed {
  height: 100vh;
  background: url(../../assets/images/login-banner.png) no-repeat fixed;
}
</style>